import React, {Component} from 'react'
import {View, Text, ScrollView, StyleSheet, Image, Dimensions,TouchableOpacity} from 'react-native'
import LoadingCommon from '../common/loading_common'
import Icon from 'react-native-vector-icons/Ionicons'
import styles,{BLUE} from '../../config/styles'
var {height, width} = Dimensions.get('window')
import ScrollableTabView from 'react-native-scrollable-tab-view'
import { VictoryBar, VictoryChart, VictoryAxis, VictoryVoronoiContainer } from 'victory-native';
import NavigatorService from '../../config/navigate_service'
import {GetStudentReports,GetClassroomReports} from '../../config/api'

import StudentStaticIndex from './student_static_index'
import ClassStaticsIndex from './class_statics_index'




class StaticsIndex extends Component {
    static navigationOptions = ({ navigation }) => {
        let options = {
            title: '自学统计',
            headerRight: <View />
        }
        return options
    }

    constructor (props) {
        super(props)
        this.state = {
            loading: false,
            staticsModels:[],
            studentModels:[]
        }
    }

    getStaticsData(){
        GetStudentReports().then((data)=>{
            if(data.code == 0){
                this.setState({
                    studentModels:data.data
                })
            }
        });

        GetClassroomReports().then((data)=>{
            if(data.code==0){
                this.setState({
                    staticsModels:data.data
                })
            }
        })
    }

    componentWillMount(){

        this.getStaticsData();

    }

    componentDidMount () {
    }

    getData = () => {
    }
    render () {
        const classStatics = this.state.staticsModels;
        const studentStatics = this.state.studentModels;

            return (
                <ScrollView style={styles.main_body}>
                    <ScrollableTabView tabBarBackgroundColor={"#fff"}
                                       tabBarActiveTextColor={BLUE}
                                       tabBarUnderlineStyle={{backgroundColor: BLUE}}>
                        <ClassStaticsIndex classStatics={classStatics} tabLabel='班级统计' />               

                        <StudentStaticIndex  studentStatics={studentStatics}  tabLabel='学生统计' />
                    </ScrollableTabView>
                </ScrollView>
            )
        }
}

export default StaticsIndex